package mysql

import "gorm.io/gorm"

type Good struct {
	gorm.Model
	GoodName  string  `gorm:"type:varchar(30);not null"`
	GoodPrice float64 `gorm:"type:decimal(10,2);not null"`
	GoodImage string  `gorm:"type:varchar(500);not null"`
	GoodStock int64   `gorm:"type:int(11);not null"`
	UserId    int64   `gorm:"type:int(11);not null"`
}

func (g *Good) GoodAdd(db *gorm.DB) error {
	return db.Debug().Create(g).Error
}

func (g *Good) FindUserByUserId(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).First(g).Error
}
